package com.dcy.command.demo;

/**
 * @Author：dcy
 * @Description:
 * @Date: 2021/1/26 8:54
 */
public class Client {

    public static void main(String[] args) {
        // 使用命令设计模式，完成通过遥控器，对电灯的操作

        //创建电灯的对象（接收者）
        LightReceiver lightReceiver = new LightReceiver();
        // 电灯相关的开关命令
        LightOffCommand lightOffCommand = new LightOffCommand(lightReceiver);
        LightOnCommand lightOnCommand = new LightOnCommand(lightReceiver);

        // 需要一个遥控器
        RemoteController remoteController = new RemoteController();
        //给我妈的遥控器设计命令，比如no = 0 是电灯的开和关操作
        remoteController.setCommand(0,lightOnCommand,lightOffCommand);

        System.out.println("按下灯的开的按钮");
        remoteController.onButtonWasPushed(0);

        System.out.println("按下灯的关的按钮");
        remoteController.offButtonWasPushed(0);

        System.out.println("按下撤销的按钮");
        remoteController.undoButtonWasPushed();
    }
}
